package com.yuuko.yuukoapi.common.response

import com.yuuko.yuukoapi.common.exception.ErrorCode
import com.yuuko.yuukoapi.model.system.Roles
import org.babyfish.jimmer.Page

class None

class AjaxResult<T>(
    val code: Int = 0,
    val message: String = "ok",
    val data: T? = null,
    val error: String? = null,
) {
    companion object {
        fun <T> ok(data: T? = null): AjaxResult<T> {
            return AjaxResult(data = data)
        }

        fun fail(code: Int = -1, message: String = "unknow error", error: String? = null): AjaxResult<None?> {
            return AjaxResult(code = code, message = message, error = error)
        }

        fun fail(code: ErrorCode, error: String? = null): AjaxResult<None?> {
            return AjaxResult(code = code.code, message = code.message, error = error)
        }
    }
}